// Author: Little09
// Problem: #2994. 「JOISC 2015 Day1」复制粘贴 2
// Contest: LibreOJ
// URL: https://loj.ac/p/2994
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// Start Time: 2023-09-26 15:45:50
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mem(x) memset(x,0,sizeof(x))
#define endl "\n"
#define printYes cout << "Yes\n"
#define printYES cout << "YES\n"
#define printNo cout << "No\n"
#define printNO cout << "NO\n"
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define mkp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,j,k) for (int i=(j);i<=(k);i++)
#define per(i,j,k) for (int i=(j);i>=(k);i--)
mt19937 rnd(time(0));
template<class T>void chkmin(T&x,T y){x=min(x,y);}
template<class T>void chkmax(T&x,T y){x=max(x,y);}

const ll inf=1000000000000000000; 
//const ll inf=1000000000;
//const ll mod=998244353;
//const ll mod=1000000007;

const int N=500005;
int k,n,m; 
char a[N];
int b[N],c[N],d[N];

int ask(int x,int y)
{
  if (y==0) return x;
  if (x<=d[y]) return ask(x,y-1);
  int len=c[y]-b[y]+1;
  if (x<=d[y]+len) return ask(x-d[y]+b[y]-1,y-1);
  return ask(x-len,y-1);
}

int main()
{
  freopen("copy.in","r",stdin);
  freopen("copy.out","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  cin >> k >> m;
  cin >> (a+1);
  cin >> n;
  rep(i,1,n) cin >> b[i] >> c[i] >> d[i];
  rep(i,1,n) b[i]++;
  rep(i,1,k) cout << a[ask(i,n)];
  return 0;
}